<template>
  <div>

    <h1>欢迎来到  {{uname}}  的店铺</h1>
    <br>
    <br>
    <br>

    <button @click="add">添加商品</button>
    <table>
      <tr>
        <td>id</td>
        <td>店主</td>
        <td>商品名称</td>
        <td>
          <button @click="huan('price')" v-model="show">商品价格</button>
        </td>
        <td>商品图片</td>
        <td>操作</td>

      </tr>
      <tr v-for="(i,j) in goodslist">
        <td>{{j}}</td>
        <td>{{i.userid.username}}</td>
        <td>{{i.name}}</td>
        <td>{{i.price}}</td>
        <td>
          <img :src="'http://localhost:8000'+i.img" alt="" width="100" height="100">
        </td>
        <td>
          <button @click="deletes(i.id)">删除</button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "day1019_oneshow",
  data() {
    return {
      goodslist:[],
      uname:localStorage.getItem('uname'),
      userid:localStorage.getItem('userid'),
      show:true

    }
  },
  methods: {
    get_goods(){
      this.$axios.get('user/shop/?userid='+this.userid).then(res=>{
        this.goodslist =res.data.list

      })
    },
    deletes(id){
      this.$axios.delete('user/shop/?id='+id).then(res=>{
        this.get_goods()
      })
    },
    add(){
      this.$router.push('day1019_add')
    },
    huan(types){
      this.$axios.get('user/change/?types='+types)
    }
  },
  mounted() {
    this.get_goods()
  }

}
</script>

<style scoped>

</style>
